//
// Created by Martin on 2022/4/8.
//
#include "leetcode102.hpp"
#include <iostream>

using namespace std;

void printResult(vector<vector<int>>& vec) {

    for (int i = 0; i < vec.size(); ++i) {
        for (int j = 0; j < vec[i].size(); ++j) {
            cout << vec[i][j];
            if (j != vec[i].size() - 1) {
                cout << ',';
            }
        }
        if (i != vec.size() - 1) {
            cout << ',';
        }
    }
    cout << endl;
}

int main()
{
    Solution s;

    { // test case 1
        // input: [3,9,20,null,null,15,7]
        // output: [3,9,20,15,7]
        vector<vector<int>> res;
        TreeNode root(3), n1(9), n2(20), n3(15), n4(7);
        root.left = &n1;
        root.right = &n2;
        n2.left = &n3;
        n2.right = &n4;

        res = s.levelOrder(&root);
        printResult(res);
    }

    { // test case 2
        // input: [1]
        // output: [1]
        vector<vector<int>> res;
        TreeNode root(1);

        res = s.levelOrder(&root);
        printResult(res);
    }

    { // test case 3
        // input: []
        // output: []
        vector<vector<int>> res;
        res = s.levelOrder(nullptr);
        printResult(res);
    }

    return 0;
}
